<template>
  <div class="container">
    <van-tabs v-model="active">
      <template v-for="item in classes.children">
        <van-tab :key="item.id" :title="item.name">
          <course-list type="0" :cate="item.id"></course-list>
        </van-tab>
      </template>
    </van-tabs>
  </div>
</template>
<script>
import courseList from '@/components/course-list'

export default {
  components: {
    courseList
  },
  data () {
    return {
      classes: [],
      active: 0,
      type: 'file'
    }
  },
  created () {
    const { type } = this.$route.params
    if (type === 'file') {
      this.active = 1
    }
    this.getClass()
  },
  methods: {
    getClass () {
      this.$axios.get('/xbkj-dj/web/edu/cate/tree').then(res => {
        this.classes = res.data[0]
      })
    }
  }
}
</script>
<style lang="less" scoped>
.van-tabs {
  /deep/ .van-tabs__nav {
    .van-tab--active {
      color: #f0321d;
    }
    .van-tabs__line {
      height: 2px;
      background-color: #f0321d;
    }
  }
}
</style>
